package com.tomorrow.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RefreshScope
public class ControllerB {
    @Autowired
    private RestTemplate restTemplate;

    /*@Autowired
    private ConfigurableApplicationContext applicationContext;*/
    @Value("${jdbc.username}")
    public String username;

    @GetMapping("/bb")
    public String BBtoCC(){
        //http://nacos-discovery-serviceB/cc
        String result = restTemplate.getForObject("http://localhost:89/cc", String.class);

        /*// 从配置中心里新添加的配置中获取相关的配置信息
        String username = applicationContext.getEnvironment().getProperty("jdbc.username");*/
        return "Service A to " + result;
    }
}